﻿namespace WpfMutipleLanguageAPP
{
    using System.Windows;
    using Stee.CAP8.WpfMutipleLanguageLib;
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class IncidentWindow : Window
    {
        public IncidentWindow()
        {
            InitializeComponent();

            //设置初始语言，默认是"en-US"，中文是"zh-HK"
            LanguageSettings.Initializationlanguage(LanguageSettings.USLang);

            //根据key返回指定语言value示例
            var name = LanguageSettings.GetSpecifyValueByKey(LanguageSettings.HKLang, "Window_Incident_Text_Jordan");
            txtName.Text = name;


            //使用model和英文字段返回当前对应语言,避免开发者自己去判断当前使用那个语言字段
            Student st = new Student();
            st.Name = "jay";
            st.Course = "Physics class";
            st.Course_HK = "物理课";
            var course = LanguageSettings.GetDataBaseCurrentValue(st, "Course");
            lblCourse.Content = course;
        }

        int i = 0;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var localisedValue = LanguageSettings.GetCurrentValueByKey("LanguageResourcesLib:IncidentForm:Window_Incident_Message_Save");
            i++;
            //使用占位符给资源资源信息中增加内容示例
            localisedValue = string.Format(localisedValue, i);
            MessageBox.Show(localisedValue);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            CfatsisWindow sw = new CfatsisWindow();
            sw.Show();
        }


        public class Student
        {
            /// <summary>
            /// 名字
            /// </summary>
            public string Name { get; set; }
            /// <summary>
            /// 课程英文字段
            /// </summary>
            public string Course { get; set; }

            /// <summary>
            /// 课程中文字段，建表时某个字段需要中英两种语言，中文字段命名规则是在英文字段后面加上“_HK”
            /// </summary>
            public string Course_HK { get; set; }
        }
    }
}
